<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- Use correct character set. -->
    <meta charset="utf-8" />
    <!-- Tell IE to use the latest, best version. -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
    />
    <title>Hello World!</title>
    <!-- <script src="../Build/Cesium/Cesium.js"></script> -->
    <script src="../Build/CesiumUnminified/Cesium.js"></script>
    <script src="jquery-2.0.3.js"></script>
    <style>
      @import url(../Build/Cesium/Widgets/widgets.css);

      html,
      body,
      #cesiumContainer {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: hidden;
      }
    </style>
  </head>

  <body>
    <div id="cesiumContainer"></div>
    <script>
      var DemoTileProvider = function DemoTileProvider() {
        this._quadtree = undefined;
        this._tilingScheme = new Cesium.GeographicTilingScheme();
        this._errorEvent = new Cesium.Event();
        this._levelZeroMaximumError = Cesium.QuadtreeTileProvider.computeDefaultLevelZeroMaximumGeometricError(
          this._tilingScheme
        );
        this.cartographicLimitRectangle = Cesium.Rectangle.clone(
          Cesium.Rectangle.MAX_VALUE
        );
      };
      Object.defineProperties(Cesium, DemoTileProvider.prototype, {
        quadtree: {
          get: function () {
            return this._quadtree;
          },
          set: function (value) {
            this._quadtree = value;
          },
        },
        ready: {
          get: function () {
            return true;
          },
        },
        tilingScheme: {
          get: function () {
            return this._tilingScheme;
          },
        },
        errorEvent: {
          get: function () {
            return this._errorEvent;
          },
        },
      });
      var rectangleIntersectionScratch = new Cesium.Rectangle();
      var cornerPositionsScratch = [
        new Cesium.Cartesian3(),
        new Cesium.Cartesian3(),
        new Cesium.Cartesian3(),
        new Cesium.Cartesian3(),
      ];
      DemoTileProvider.prototype.update = function (frameState) {
        this._quadtree.beginFrame(frameState);
        this._quadtree.render(frameState);
        this._quadtree.endFrame(frameState);
      };
      DemoTileProvider.prototype.initialize = function (frameState) {};
      DemoTileProvider.prototype.beginUpdate = function (frameState) {
        // debugger
        // for (var i = 0; i < this._reTiles.length; i++) {
        //     var tile = this._reTiles[i];
        //     if (this.computeTileVisibility(tile, frameState, null) == Cesium.Visibility.NONE) {
        //         for (var key in frameState.context._pickObjects) {
        //             var obj = frameState.context._pickObjects[key];
        //             if (obj.id.indexOf('z' + tile.level + 'x' + tile.x + 'y' + tile.y + 'n') == 0) {
        //                 delete frameState.context._pickObjects[key];
        //             }
        //         }
        //     }
        // }
      };
      DemoTileProvider.prototype.endUpdate = function (frameState) {};

      DemoTileProvider.prototype.getLevelMaximumGeometricError = function (
        level
      ) {
        return this._levelZeroMaximumError / (1 << level);
      };

      var _option = JSON.parse(
        '{"show":true,"positions":[],"cornerType":0,"granularity":0.017453292519943295,"fill":"rgba(245, 60, 4, 1)","material":{"red":0.9607843137254902,"green":0.23529411764705882,"blue":0.01568627450980392,"alpha":1},"outline":false,"outlineColor":"rgba(68,66,66,0.5)","outlineWidth":1,"shadows":0,"level_max":21,"level_min":10,"extrudedHeightReference":0,"classificationType":0,"layertype":"polygonlayer","far":9999999999999,"effect":0,"extrudedHeight":"[Floor]","near":0,"heightReference":0,"height":0}'
      );
      var options = JSON.parse(
        '{"height":0,"extrudedHeight":0,"vertexFormat":{"position":true,"normal":true,"st":true,"bitangent":false,"tangent":false,"color":false},"stRotation":0,"ellipsoid":{"_radii":{"x":6378137,"y":6378137,"z":6356752.31414},"_radiiSquared":{"x":40680631590769,"y":40680631590769,"z":40408299983324.25},"_radiiToTheFourth":{"x":1.6549137866238727e+27,"y":1.6549137866238727e+27,"z":1.6328307075423225e+27},"_oneOverRadii":{"x":1.567855942887398e-7,"y":1.567855942887398e-7,"z":1.5731303511316519e-7},"_oneOverRadiiSquared":{"x":2.458172257647332e-14,"y":2.458172257647332e-14,"z":2.4747391016515947e-14},"_minimumRadius":6356752.31414,"_maximumRadius":6378137,"_centerToleranceSquared":0.1,"_squaredXOverSquaredZ":1.0067394967755916},"perPositionHeight":false,"closeTop":true,"closeBottom":true,"arcType":1,"material":{"red":1,"green":0,"blue":0,"alpha":1},"id":"3BB32294"}'
      );

      var styleOption = JSON.parse(
        '{"layertype":"modellayer","level_max":21,"color":{"red":0.8392156862745098,"green":0.19215686274509805,"blue":0.19215686274509805,"alpha":0.5},"far":99999999999,"lightColor":"rgba(18, 18, 133, 0.5)","scale":30,"level_min":0,"near":1,"heightReference":0,"uri":"http://36.7.136.132:8099/img/model/飞机1.gltf","collect":false,"height":0}'
      );
      var options = JSON.parse(
        '{"url":"","color":{"red":0.8392156862745098,"green":0.19215686274509805,"blue":0.19215686274509805,"alpha":0.5},"scale":100,"layertype":"modellayer","level_max":21,"far":99999999999,"lightColor":"rgba(18, 18, 133, 0.5)","level_min":0,"near":1,"heightReference":0,"uri":"http://36.7.136.132:8099/img/model/飞机1.gltf","collect":false,"height":0,"distanceDisplayCondition":{"_near":1,"_far":99999999999}}'
      );

      DemoTileProvider.prototype.loadTile = function (frameState, tile) {
        if (tile.state === Cesium.QuadtreeTileLoadState.START) {
          tile.data = {
            lines: [],
            geometryPrimitive: undefined,
          };

          if (4 < tile.level && tile.level < 21) {
            var tileUrl = "http://192.168.1.40:8090/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=swagger:_20200509160140_zirancun&STYLE=&TILEMATRIX=EPSG%3A4326%3A%7Bz%7D&TILEMATRIXSET=EPSG%3A4326&format=application%2Fjson%3Btype%3Dgeojson&TILECOL=%7Bx%7D&TILEROW=%7By%7D"
              .replace(window.encodeURIComponent("{x}"), tile.x)
              .replace(window.encodeURIComponent("{y}"), tile.y)
              .replace(window.encodeURIComponent("{z}"), tile.level);
            var tileUrl = "http://192.168.1.40:8090/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=swagger:_20200410135144_gouwu2&STYLE=&TILEMATRIX=EPSG%3A4326%3A%7Bz%7D&TILEMATRIXSET=EPSG%3A4326&format=application%2Fjson%3Btype%3Dgeojson&TILECOL=%7Bx%7D&TILEROW=%7By%7D"
              .replace(window.encodeURIComponent("{x}"), tile.x)
              .replace(window.encodeURIComponent("{y}"), tile.y)
              .replace(window.encodeURIComponent("{z}"), tile.level);
            fetch(tileUrl, {
              method: "get",
              headers: {
                // 'Content-Type': 'application/json'
              },
            })
              .then(function (response) {
                return response.json();
              })
              .then(function (data) {
                // })
                // $.ajax({//_20200819030638_export_output_2
                //     url: tileUrl,
                //     type: "get",
                //     dataType: "json",
                //     success: function(data) {
                if (data == undefined) {
                  tile.state = Cesium.QuadtreeTileLoadState.DONE;
                  tile.renderable = true;
                  return;
                }
                var collection = new Cesium.PrimitiveCollection({
                  isModel: true,
                });
                var instances = [];
                data.features.forEach(function (feature) {
                  options.id = feature;
                  //修改xp
                  var sheight = feature.geometry.coordinates[2] || 0;
                  if (feature.properties.height != undefined) {
                    sheight = parseFloat(feature.properties.height);
                  }
                  //取坐标高度
                  if (
                    /^\[/.test(options.height) &&
                    /\]$/.test(options.height)
                  ) {
                    var extrudedHeight = options.height
                      .replace(/\[/, "")
                      .replace(/\]/, "");
                    sheight += parseFloat(feature.properties[extrudedHeight]);
                  } else {
                    sheight += parseFloat(options.height) || 0;
                  }
                  tile._maximumHeight =
                    tile._maximumHeight > sheight
                      ? tile._maximumHeight
                      : sheight;
                  tile._minimumHeight =
                    tile._minimumHeight < sheight
                      ? tile._minimumHeight
                      : sheight;
                  // options.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(feature.geometry.coordinates[0], feature.geometry.coordinates[1], 100));

                  // var position = Cesium.Cartesian3.fromDegrees(feature.geometry.coordinates[0], feature.geometry.coordinates[1], 100);
                  // var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(position, new Cesium.HeadingPitchRoll(0, 0, 0));
                  modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
                    Cesium.Cartesian3.fromDegrees(
                      feature.geometry.coordinates[0],
                      feature.geometry.coordinates[1],
                      100
                    )
                  );
                  Cesium.Matrix4.multiplyByUniformScale(
                    modelMatrix,
                    2,
                    modelMatrix
                  );
                  instances.push({
                    modelMatrix: modelMatrix,
                    modelId: feature,
                  });
                });

                if (data.features.length == 0) {
                  tile.state = Cesium.QuadtreeTileLoadState.DONE;
                  tile.renderable = true;
                }
                //  var c = that._Provider._PrimitiveCollection.add(collection);
                //  tile._PrimitiveCollection = that._Provider._PrimitiveCollection;
                // tile.customDatazh.push(c);
                var p = new Cesium.ModelInstanceCollectionzh({
                  url: "http://36.7.136.132:8099/img/model/飞机1.gltf",
                  instances: instances,
                  color: Cesium.Color.ORANGERED,
                });
                tile.data.geometryPrimitive = p;
                tile.state = Cesium.QuadtreeTileLoadState.LOADING;
                if (tile.state === Cesium.QuadtreeTileLoadState.LOADING) {
                  // if (tile.data.geometryPrimitive && tile.data.geometryPrimitive._isModel&& tile.data.geometryPrimitive._primitives)
                  // for (var ii = 0, ll = tile.data.geometryPrimitive._primitives.length; ii < ll; ii++)
                  //     tile.data.geometryPrimitive._primitives[ii]._isRender = 1;
                  tile.data.geometryPrimitive.update(frameState, []);
                  //if (tile.data.geometryPrimitive._ready) {
                  tile.state = Cesium.QuadtreeTileLoadState.DONE;
                  tile.renderable = true;
                  //}
                }
                // },
                // error: function() {
                //     tile.state = Cesium.QuadtreeTileLoadState.DONE;
                //     tile.renderable = true;
                //     return;
                // }
              });

            // })(frameState, tile);
            // Create random lines at the root level.
          } else {
            tile.state = Cesium.QuadtreeTileLoadState.DONE;
            tile.renderable = true;
            // Add more detail to parent lines at every other level.
            return;
          }

          tile.state = Cesium.QuadtreeTileLoadState.LOADING;
        }
      };

      DemoTileProvider.prototype.computeTileVisibility = function (
        tile,
        frameState,
        occluders
      ) {
        var distance = this.computeDistanceToTile(tile, frameState);
        tile._distance = distance;

        if (frameState.fog.enabled) {
          if (Cesium.Math.fog(distance, frameState.fog.density) >= 1.0) {
            // Tile is completely in fog so return that it is not visible.
            if (tile.data.geometryPrimitive) {
              // console.log('none')
              tile.data = undefined;
            }
            return Cesium.Visibility.NONE;
          }
        }

        var surfaceTile = tile.data;
        var tileBoundingRegion = surfaceTile.tileBoundingRegion;

        if (surfaceTile.boundingVolumeSourceTile === undefined) {
          // We have no idea where this tile is, so let's just call it partially visible.
          return Cesium.Visibility.PARTIAL;
        }

        var cullingVolume = frameState.cullingVolume;
        var boundingVolume = surfaceTile.orientedBoundingBox;

        if (!boundingVolume && surfaceTile.renderedMesh) {
          boundingVolume = surfaceTile.renderedMesh.boundingSphere3D;
        }

        // Check if the tile is outside the limit area in cartographic space
        surfaceTile.clippedByBoundaries = false;
        var clippedCartographicLimitRectangle = clipRectangleAntimeridian(
          tile.rectangle,
          this.cartographicLimitRectangle
        );
        var areaLimitIntersection = Cesium.Rectangle.simpleIntersection(
          clippedCartographicLimitRectangle,
          tile.rectangle,
          rectangleIntersectionScratch
        );
        if (!areaLimitIntersection) {
          if (tile.data.geometryPrimitive) {
            // console.log('none')
            // tile.data = undefined;
          }
          return Cesium.Visibility.NONE;
        }
        if (!Cesium.Rectangle.equals(areaLimitIntersection, tile.rectangle)) {
          surfaceTile.clippedByBoundaries = true;
        }

        if (frameState.mode !== Cesium.SceneMode.SCENE3D) {
          boundingVolume = boundingSphereScratch;
          BoundingSphere.fromRectangleWithHeights2D(
            tile.rectangle,
            frameState.mapProjection,
            tileBoundingRegion.minimumHeight,
            tileBoundingRegion.maximumHeight,
            boundingVolume
          );
          Cartesian3.fromElements(
            boundingVolume.center.z,
            boundingVolume.center.x,
            boundingVolume.center.y,
            boundingVolume.center
          );

          if (
            frameState.mode === SceneMode.MORPHING &&
            surfaceTile.renderedMesh
          ) {
            boundingVolume = BoundingSphere.union(
              surfaceTile.renderedMesh.boundingSphere3D,
              boundingVolume,
              boundingVolume
            );
          }
        }

        if (!boundingVolume) {
          return Cesium.Intersect.INTERSECTING;
        }

        var clippingPlanes = this._clippingPlanes;
        if (clippingPlanes && clippingPlanes.enabled) {
          var planeIntersection = clippingPlanes.computeIntersectionWithBoundingVolume(
            boundingVolume
          );
          tile.isClipped = planeIntersection !== Intersect.INSIDE;
          if (planeIntersection === Cesium.Intersect.OUTSIDE) {
            if (tile.data.geometryPrimitive) {
              // console.log('none')
              tile.data = undefined;
            }
            return Cesium.Visibility.NONE;
          }
        }

        var intersection = cullingVolume.computeVisibility(boundingVolume);
        if (intersection === Cesium.Intersect.OUTSIDE) {
          if (tile.data.geometryPrimitive) {
            // console.log('none')
            // tile.data = undefined;
          }
          return Cesium.Visibility.NONE;
        }

        var ortho3D =
          frameState.mode === Cesium.SceneMode.SCENE3D &&
          frameState.camera.frustum instanceof Cesium.OrthographicFrustum;
        if (
          frameState.mode === Cesium.SceneMode.SCENE3D &&
          !ortho3D &&
          occluders
        ) {
          var occludeePointInScaledSpace =
            surfaceTile.occludeePointInScaledSpace;
          if (!occludeePointInScaledSpace) {
            return intersection;
          }

          if (
            occluders.ellipsoid.isScaledSpacePointVisible(
              occludeePointInScaledSpace
            )
          ) {
            return intersection;
          }

          if (tile.data.geometryPrimitive) {
            // console.log('none')
            // tile.data = undefined;
          }
          return Cesium.Visibility.NONE;
        }

        return intersection;
      };
      DemoTileProvider.prototype.canRefine = function (
        tile,
        frameState,
        occluders
      ) {
        if (tile.level < 21) return true;
        return false;
      };
      DemoTileProvider.prototype.computeDistanceToTile = function (
        tile,
        frameState
      ) {
        // The distance should be:
        // 1. the actual distance to the tight-fitting bounding volume, or
        // 2. a distance that is equal to or greater than the actual distance to the tight-fitting bounding volume.
        //
        // When we don't know the min/max heights for a tile, but we do know the min/max of an ancestor tile, we can
        // build a tight-fitting bounding volume horizontally, but not vertically. The min/max heights from the
        // ancestor will likely form a volume that is much bigger than it needs to be. This means that the volume may
        // be deemed to be much closer to the camera than it really is, causing us to select tiles that are too detailed.
        // Loading too-detailed tiles is super expensive, so we don't want to do that. We don't know where the child
        // tile really lies within the parent range of heights, but we _do_ know the child tile can't be any closer than
        // the ancestor height surface (min or max) that is _farthest away_ from the camera. So if we compute distance
        // based that conservative metric, we may end up loading tiles that are not detailed enough, but that's much
        // better (faster) than loading tiles that are too detailed.

        var heightSource = updateTileBoundingRegion(
          tile,
          this.terrainProvider,
          frameState
        );
        var surfaceTile = tile.data;
        var tileBoundingRegion = surfaceTile.tileBoundingRegion;

        if (heightSource === undefined) {
          // Can't find any min/max heights anywhere? Ok, let's just say the
          // tile is really far away so we'll load and render it rather than
          // refining.
          return 9999999999.0;
        } else if (surfaceTile.boundingVolumeSourceTile !== heightSource) {
          // Heights are from a new source tile, so update the bounding volume.
          surfaceTile.boundingVolumeSourceTile = heightSource;

          var rectangle = tile.rectangle;
          if (
            rectangle &&
            rectangle.width < Cesium.Math.PI_OVER_TWO + Cesium.Math.EPSILON5
          ) {
            surfaceTile.orientedBoundingBox = Cesium.OrientedBoundingBox.fromRectangle(
              tile.rectangle,
              tileBoundingRegion.minimumHeight,
              tileBoundingRegion.maximumHeight,
              tile.tilingScheme.ellipsoid,
              surfaceTile.orientedBoundingBox
            );

            surfaceTile.occludeePointInScaledSpace = computeOccludeePoint(
              this,
              surfaceTile.orientedBoundingBox.center,
              tile.rectangle,
              tileBoundingRegion.maximumHeight,
              surfaceTile.occludeePointInScaledSpace
            );
          }
        }

        var min = tileBoundingRegion.minimumHeight;
        var max = tileBoundingRegion.maximumHeight;

        if (surfaceTile.boundingVolumeSourceTile !== tile) {
          var cameraHeight = frameState.camera.positionCartographic.height;
          var distanceToMin = Math.abs(cameraHeight - min);
          var distanceToMax = Math.abs(cameraHeight - max);
          if (distanceToMin > distanceToMax) {
            tileBoundingRegion.minimumHeight = min;
            tileBoundingRegion.maximumHeight = min;
          } else {
            tileBoundingRegion.minimumHeight = max;
            tileBoundingRegion.maximumHeight = max;
          }
        }

        var result = tileBoundingRegion.distanceToCamera(frameState);

        tileBoundingRegion.minimumHeight = min;
        tileBoundingRegion.maximumHeight = max;

        return result;
      };

      function updateTileBoundingRegion(tile, terrainProvider, frameState) {
        var surfaceTile = tile.data;
        if (surfaceTile === undefined) {
          surfaceTile = tile.data = new Cesium.GlobeSurfaceTile();
        }

        if (surfaceTile.tileBoundingRegion === undefined) {
          surfaceTile.tileBoundingRegion = new Cesium.TileBoundingRegion({
            computeBoundingVolumes: false,
            rectangle: tile.rectangle,
            ellipsoid: tile.tilingScheme.ellipsoid,
            minimumHeight: 0.0,
            maximumHeight: 0.0,
          });
        }
        return tile;
      }

      function clipRectangleAntimeridian(
        tileRectangle,
        cartographicLimitRectangle
      ) {
        if (cartographicLimitRectangle.west < cartographicLimitRectangle.east) {
          return cartographicLimitRectangle;
        }
        var splitRectangle = Rectangle.clone(
          cartographicLimitRectangle,
          splitCartographicLimitRectangleScratch
        );
        var tileCenter = Rectangle.center(
          tileRectangle,
          rectangleCenterScratch
        );
        if (tileCenter.longitude > 0.0) {
          splitRectangle.east = CesiumMath.PI;
        } else {
          splitRectangle.west = -CesiumMath.PI;
        }
        return splitRectangle;
      }

      function computeOccludeePoint(
        tileProvider,
        center,
        rectangle,
        height,
        result
      ) {
        var ellipsoidalOccluder = tileProvider.quadtree._occluders.ellipsoid;
        var ellipsoid = ellipsoidalOccluder.ellipsoid;

        var cornerPositions = cornerPositionsScratch;
        Cesium.Cartesian3.fromRadians(
          rectangle.west,
          rectangle.south,
          height,
          ellipsoid,
          cornerPositions[0]
        );
        Cesium.Cartesian3.fromRadians(
          rectangle.east,
          rectangle.south,
          height,
          ellipsoid,
          cornerPositions[1]
        );
        Cesium.Cartesian3.fromRadians(
          rectangle.west,
          rectangle.north,
          height,
          ellipsoid,
          cornerPositions[2]
        );
        Cesium.Cartesian3.fromRadians(
          rectangle.east,
          rectangle.north,
          height,
          ellipsoid,
          cornerPositions[3]
        );

        return ellipsoidalOccluder.computeHorizonCullingPoint(
          center,
          cornerPositions,
          result
        );
      }
      DemoTileProvider.prototype.isDestroyed = function () {
        return false;
      };
      DemoTileProvider.prototype.destroy = function () {
        return Cesium.destroyObject(this);
      };
      DemoTileProvider.prototype.updateForPick = function (frameState) {
        // Add the tile pick commands from the tiles drawn last frame.
        // var drawCommands = this._drawCommands;
        // for (var i = 0, length = this._usedDrawCommands; i < length; ++i) {
        //     frameState.commandList.push(drawCommands[i]);
        // }
      };
      // var viewer = new Cesium.Viewer('cesiumContainer');

      DemoTileProvider.prototype.showTileThisFrame = function (
        tile,
        frameState
      ) {
        // if (tile.data.geometryPrimitive && tile.data.geometryPrimitive._isModel)
        //     for (var i = 0, l = tile.data.geometryPrimitive.length; i < l; i++)
        //         tile.data.geometryPrimitive[i]._isRender = 1;
        // else
        if (tile.data.geometryPrimitive)
          tile.data.geometryPrimitive.update(frameState);
        // if (!tile.data) {
        //     tile.state = Cesium.QuadtreeTileLoadState.START;
        //     return;
        // }
        // if (tile.data && tile.data.geometryPrimitive)
        //     tile.data.geometryPrimitive.update(context, frameState, commandList);
        //     // tile.data.geometryPrimitive._isUpdateQuad = 1;
        // c1.update(scene._frameState)
      };
      var viewer = new Cesium.Viewer("cesiumContainer", {
        //需要进行可视化的数据源的集合
        animation: false, //是否显示动画控件
        shouldAnimate: true,
        homeButton: false, //是否显示Home按钮
        fullscreenButton: false, //是否显示全屏按钮
        baseLayerPicker: false, //是否显示图层选择控件
        geocoder: false, //是否显示地名查找控件
        timeline: false, //是否显示时间线控件
        sceneModePicker: true, //是否显示投影方式控件
        navigationHelpButton: false, //是否显示帮助信息控件
        infoBox: false, //是否显示点击要素之后显示的信息
        requestRenderMode: true, //启用请求渲染模式
        scene3DOnly: false, //每个几何实例将只能以3D渲染以节省GPU内存
        sceneMode: 3, //初始场景模式 1 2D模式 2 2D循环模式 3 3D模式  Cesium.SceneMode
        fullscreenElement: document.body, //全屏时渲染的HTML元素 暂时没发现用处
        //天地图是官方开元的地图，不需要密钥
        imageryProvider: new Cesium.UrlTemplateImageryProvider({
          url:
            "http://mt1.google.cn/vt/lyrs=s&hl=zh-CN&x={x}&y={y}&z={z}&s=Gali",
        }),
      });

      var scene = viewer.scene;
      var primitives = scene.primitives;

      var prim = new Cesium.QuadtreePrimitive({
        // var prim = new Cesium.QuadtreePrimitive({
        tileProvider: new DemoTileProvider(),
        tileCacheSize: 1,
        maximumScreenSpaceError: 30,
      });
      scene.primitivesQuadTrees.push(prim);
      primitives.add(prim);

      // // 1. Draw a translucent ellipse on the surface with a checkerboard pattern
      // var instance = new Cesium.GeometryInstance({
      //     geometry: new Cesium.EllipseGeometry({
      //         center: Cesium.Cartesian3.fromDegrees(-100.0, 20.0),
      //         semiMinorAxis: 500000.0,
      //         semiMajorAxis: 1000000.0,
      //         rotation: Cesium.Math.PI_OVER_FOUR,
      //         vertexFormat: Cesium.VertexFormat.POSITION_AND_ST
      //     }),
      //     id: 'object returned when this instance is picked and to get/set per-instance attributes'
      // });
      // var c = new Cesium.Primitive({
      //     geometryInstances: instance,
      //     appearance: new Cesium.EllipsoidSurfaceAppearance({
      //         material: Cesium.Material.fromType('Checkerboard')
      //     })
      // });
      // scene._frameState.passes.render = true;
      // scene.primitives.add(c);
      // // c.update(scene._frameState, []);

      // var rectangleInstance = new Cesium.GeometryInstance({
      //     geometry: new Cesium.RectangleGeometry({
      //         rectangle: Cesium.Rectangle.fromDegrees(-140.0, 30.0, -100.0, 40.0),
      //         vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
      //     }),
      //     attributes: {
      //         color: new Cesium.ColorGeometryInstanceAttribute(0.0, 1.0, 1.0, 0.5)
      //     }
      // });
      // var ellipsoidInstance = new Cesium.GeometryInstance({
      //     geometry: new Cesium.EllipsoidGeometry({
      //         radii: new Cesium.Cartesian3(500000.0, 500000.0, 1000000.0),
      //         vertexFormat: Cesium.VertexFormat.POSITION_AND_NORMAL
      //     }),
      //     modelMatrix: Cesium.Matrix4.multiplyByTranslation(Cesium.Transforms.eastNorthUpToFixedFrame(
      //         Cesium.Cartesian3.fromDegrees(-95.59777, 40.03883)), new Cesium.Cartesian3(0.0, 0.0, 500000.0), new Cesium.Matrix4()),
      //     attributes: {
      //         color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
      //     }
      // });

      // var c1 = new Cesium.Primitive({
      //     geometryInstances: [rectangleInstance, ellipsoidInstance],
      //     appearance: new Cesium.PerInstanceColorAppearance()
      // });

      // c1.update(scene._frameState, []);
      // scene.primitives.add(c1);

      // function leftClickEvent(e) {

      //     var Viewer = viewer;
      //     var leftPickPoint_eventListener = new Cesium.ScreenSpaceEventHandler(Viewer.scene.canvas);
      //     leftPickPoint_eventListener.setInputAction(function(movement) {
      //         var pickedObject = Viewer.scene.pick(movement.position);

      //         debugger

      //     }, Cesium.ScreenSpaceEventType.LEFT_CLICK)
      // }

      // var data = { "type": "FeatureCollection", "totalFeatures": "unknown", "features": [{ "type": "Feature", "id": "_20200410135144_gouwu2.0", "geometry": { "type": "Point", "coordinates": [118.76919, 32.05639] }, "geometry_name": "geom", "properties": { "Class": "0X44FF", "Name": "白领女装" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.1", "geometry": { "type": "Point", "coordinates": [118.76924, 32.05628] }, "geometry_name": "geom", "properties": { "Class": "0X44FF", "Name": "热选" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.2", "geometry": { "type": "Point", "coordinates": [118.7694, 32.05902] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "华诚便利店(上海路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.3", "geometry": { "type": "Point", "coordinates": [118.769204, 32.053067] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "苏宁环球套房饭店包饼屋" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.4", "geometry": { "type": "Point", "coordinates": [118.771329, 32.061393] }, "geometry_name": "geom", "properties": { "Class": "0X4080", "Name": "宽宇购物中心" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.5", "geometry": { "type": "Point", "coordinates": [118.7697, 32.05252] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "国声音乐书城" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.6", "geometry": { "type": "Point", "coordinates": [118.777497, 32.05261] }, "geometry_name": "geom", "properties": { "Class": "0X4750", "Name": "别克专卖店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.7", "geometry": { "type": "Point", "coordinates": [118.77236, 32.05237] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "元祖食品(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.8", "geometry": { "type": "Point", "coordinates": [118.77215, 32.05238] }, "geometry_name": "geom", "properties": { "Class": "0X44FF", "Name": "曼奴" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.9", "geometry": { "type": "Point", "coordinates": [118.77215, 32.05238] }, "geometry_name": "geom", "properties": { "Class": "0X46FF", "Name": "超世纪sports" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.10", "geometry": { "type": "Point", "coordinates": [118.772359, 32.052365] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "外贸绸丝广州路专营店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.11", "geometry": { "type": "Point", "coordinates": [118.774505, 32.052313] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "美而易" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.12", "geometry": { "type": "Point", "coordinates": [118.773424, 32.053338] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "欧风西饼屋" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.13", "geometry": { "type": "Point", "coordinates": [118.772843, 32.053677] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "雅心书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.14", "geometry": { "type": "Point", "coordinates": [118.775555, 32.052353] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "千里马考研书店(南京分店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.15", "geometry": { "type": "Point", "coordinates": [118.775765, 32.052353] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "文曲星考试书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.16", "geometry": { "type": "Point", "coordinates": [118.775175, 32.052333] }, "geometry_name": "geom", "properties": { "Class": "0X4710", "Name": "宝岛眼镜(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.17", "geometry": { "type": "Point", "coordinates": [118.775555, 32.052353] }, "geometry_name": "geom", "properties": { "Class": "0X4710", "Name": "四明眼镜(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.18", "geometry": { "type": "Point", "coordinates": [118.777025, 32.052413] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "江苏高教书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.19", "geometry": { "type": "Point", "coordinates": [118.777025, 32.052413] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "南京法律书店(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.20", "geometry": { "type": "Point", "coordinates": [118.776385, 32.052393] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "新时空书场" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.21", "geometry": { "type": "Point", "coordinates": [118.777065, 32.052554] }, "geometry_name": "geom", "properties": { "Class": "0X4720", "Name": "古兰花卉礼品中心" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.22", "geometry": { "type": "Point", "coordinates": [118.777462, 32.052413] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "柏斯琴行" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.23", "geometry": { "type": "Point", "coordinates": [118.778626, 32.052964] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "克莉丝汀饼屋(南京渡江店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.24", "geometry": { "type": "Point", "coordinates": [118.778626, 32.052964] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "喜悦食品(中山店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.25", "geometry": { "type": "Point", "coordinates": [118.777025, 32.052413] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "欧贝拉(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.26", "geometry": { "type": "Point", "coordinates": [118.777025, 32.052413] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "圣罗兰(广州路)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.27", "geometry": { "type": "Point", "coordinates": [118.775968, 32.055906] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "南京大学出版社图书直销部" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.28", "geometry": { "type": "Point", "coordinates": [118.77077, 32.0595] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "百利通琴行" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.29", "geometry": { "type": "Point", "coordinates": [118.770507, 32.056394] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "如意烟酒店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.30", "geometry": { "type": "Point", "coordinates": [118.773472, 32.055379] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "全国连锁冷热饮料特许专卖店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.31", "geometry": { "type": "Point", "coordinates": [118.772938, 32.054903] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "苏果好的便利店(青岛路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.32", "geometry": { "type": "Point", "coordinates": [118.77365, 32.0551] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "21世纪考研书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.33", "geometry": { "type": "Point", "coordinates": [118.77388, 32.05538] }, "geometry_name": "geom", "properties": { "Class": "0X417F", "Name": "华诚超市(青岛路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.34", "geometry": { "type": "Point", "coordinates": [118.77388, 32.05538] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "万象书坊" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.35", "geometry": { "type": "Point", "coordinates": [118.77453, 32.05538] }, "geometry_name": "geom", "properties": { "Class": "0X4710", "Name": "南京明亮眼镜(汉口路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.36", "geometry": { "type": "Point", "coordinates": [118.776208, 32.055946] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "南京大学出版社书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.37", "geometry": { "type": "Point", "coordinates": [118.7761, 32.05561] }, "geometry_name": "geom", "properties": { "Class": "0X4710", "Name": "康达眼镜(汉口路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.38", "geometry": { "type": "Point", "coordinates": [118.77583, 32.05519] }, "geometry_name": "geom", "properties": { "Class": "0X417F", "Name": "江苏省教育超市(南京大学鼓楼教育超市)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.39", "geometry": { "type": "Point", "coordinates": [118.77528, 32.05632] }, "geometry_name": "geom", "properties": { "Class": "0X45FF", "Name": "思源基金电脑室" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.40", "geometry": { "type": "Point", "coordinates": [118.77849, 32.05938] }, "geometry_name": "geom", "properties": { "Class": "0X4080", "Name": "百家餐厅商业街(东门)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.41", "geometry": { "type": "Point", "coordinates": [118.77918, 32.05947] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "百家便利店(NO.1)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.42", "geometry": { "type": "Point", "coordinates": [118.77918, 32.05947] }, "geometry_name": "geom", "properties": { "Class": "0X4080", "Name": "百家餐厅商业街(西门)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.43", "geometry": { "type": "Point", "coordinates": [118.77969, 32.052] }, "geometry_name": "geom", "properties": { "Class": "0X4710", "Name": "四明钟表店眼镜配戴中心(珠江路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.44", "geometry": { "type": "Point", "coordinates": [118.779111, 32.051871] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "中山卷烟专营店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.45", "geometry": { "type": "Point", "coordinates": [118.77348, 32.05176] }, "geometry_name": "geom", "properties": { "Class": "0X4380", "Name": "典雅坊家具" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.46", "geometry": { "type": "Point", "coordinates": [118.77407, 32.05195] }, "geometry_name": "geom", "properties": { "Class": "0X4400", "Name": "采蝶轩蛋糕坊(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.47", "geometry": { "type": "Point", "coordinates": [118.77407, 32.05195] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "常青藤食品(NO.004)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.48", "geometry": { "type": "Point", "coordinates": [118.77686, 32.0519] }, "geometry_name": "geom", "properties": { "Class": "0X4760", "Name": "江苏嘉禾国际拍卖有限公司" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.49", "geometry": { "type": "Point", "coordinates": [118.77738, 32.05159] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "苏果好的便利店(千河沿前街店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.50", "geometry": { "type": "Point", "coordinates": [118.77388, 32.05193] }, "geometry_name": "geom", "properties": { "Class": "0X4600", "Name": "南京易事达文具(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.51", "geometry": { "type": "Point", "coordinates": [118.77211, 32.05625] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "复兴书店" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.52", "geometry": { "type": "Point", "coordinates": [118.77864, 32.05384] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "苏果好的便利店(中山路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.53", "geometry": { "type": "Point", "coordinates": [118.77848, 32.05415] }, "geometry_name": "geom", "properties": { "Class": "0X417F", "Name": "南京苏源超市(中山路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.54", "geometry": { "type": "Point", "coordinates": [118.778654, 32.054161] }, "geometry_name": "geom", "properties": { "Class": "0X4180", "Name": "精达电器集团南京总代理" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.55", "geometry": { "type": "Point", "coordinates": [118.77863, 32.05341] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "协和琴行" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.56", "geometry": { "type": "Point", "coordinates": [118.778123, 32.056114] }, "geometry_name": "geom", "properties": { "Class": "0X4730", "Name": "南京市照相器材专业市场" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.57", "geometry": { "type": "Point", "coordinates": [118.77946, 32.05998] }, "geometry_name": "geom", "properties": { "Class": "0X4300", "Name": "手机城" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.58", "geometry": { "type": "Point", "coordinates": [118.77928, 32.05979] }, "geometry_name": "geom", "properties": { "Class": "0X4300", "Name": "邮政大厦手机城" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.59", "geometry": { "type": "Point", "coordinates": [118.77928, 32.05979] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "大众书局(鼓楼店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.60", "geometry": { "type": "Point", "coordinates": [118.779111, 32.051871] }, "geometry_name": "geom", "properties": { "Class": "0X40C0", "Name": "中山大厦商场(南门)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.61", "geometry": { "type": "Point", "coordinates": [118.77911, 32.05148] }, "geometry_name": "geom", "properties": { "Class": "0X4494", "Name": "七匹狼(中山路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.62", "geometry": { "type": "Point", "coordinates": [118.779111, 32.051871] }, "geometry_name": "geom", "properties": { "Class": "0X40C0", "Name": "太平商场羽绒城(中山大厦店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.63", "geometry": { "type": "Point", "coordinates": [118.77937, 32.05203] }, "geometry_name": "geom", "properties": { "Class": "0X40C0", "Name": "中山大厦商场(北门)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.64", "geometry": { "type": "Point", "coordinates": [118.77969, 32.052] }, "geometry_name": "geom", "properties": { "Class": "0X44FF", "Name": "太平羽绒服分会场" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.65", "geometry": { "type": "Point", "coordinates": [118.77487, 32.05196] }, "geometry_name": "geom", "properties": { "Class": "0X47FF", "Name": "江苏烟草苏捷连锁(NO.026)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.66", "geometry": { "type": "Point", "coordinates": [118.77487, 32.05196] }, "geometry_name": "geom", "properties": { "Class": "0X4010", "Name": "苏果便利店(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.67", "geometry": { "type": "Point", "coordinates": [118.77626, 32.05195] }, "geometry_name": "geom", "properties": { "Class": "0X457F", "Name": "天平法律书店(广州路店)" } }, { "type": "Feature", "id": "_20200410135144_gouwu2.68", "geometry": { "type": "Point", "coordinates": [118.77706, 32.05202] }, "geometry_name": "geom", "properties": { "Class": "0X44FF", "Name": "蜻蜓必佳(广州路店)" } }] }
      // var i = 0;
      // var collection = new Cesium.PrimitiveCollection({ isModel: true });
      // var instances = [];
      // data.features.forEach(function(feature) {

      //     //options.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(feature.geometry.coordinates[0], feature.geometry.coordinates[1], 100));

      //     var position = Cesium.Cartesian3.fromDegrees(feature.geometry.coordinates[0], feature.geometry.coordinates[1], 100);

      //     var heading = Math.random();
      //     var pitch = Math.random();
      //     var roll = Math.random();

      //     var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(position, new Cesium.HeadingPitchRoll(heading, pitch, roll));
      //     Cesium.Matrix4.multiplyByUniformScale(modelMatrix, 1, modelMatrix);
      //     instances.push({ modelMatrix: modelMatrix })
      //     // }
      // });

      // var collection = viewer.scene.primitives.add(new Cesium.ModelInstanceCollectionzh({
      //     url: "http://36.7.136.132:8099/img/model/飞机1.gltf",
      //     instances: instances,
      //     color: Cesium.Color.ORANGERED
      // }));

      // var instances = [];
      // var gridSize = Math.sqrt(300);
      // var centerLongitude = 118.77407
      // var centerLatitude = 32.05195
      // var spacing = 0.1
      // for (var y = 0; y < gridSize; ++y) {
      //     for (var x = 0; x < gridSize; ++x) {
      //         var longitude = centerLongitude + spacing * (x - gridSize / 2);
      //         var latitude = centerLatitude + spacing * (y - gridSize / 2);
      //         var position = Cesium.Cartesian3.fromDegrees(longitude, latitude, 100);

      //         var heading = Math.random();
      //         var pitch = Math.random();
      //         var roll = Math.random();
      //         var scale = (Math.random() + 1.0) / 2.0;

      //         var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(position, new Cesium.HeadingPitchRoll(heading, pitch, roll));
      //         Cesium.Matrix4.multiplyByUniformScale(modelMatrix, 100, modelMatrix);

      //         instances.push({
      //             modelMatrix: modelMatrix
      //         });
      //     }
      // }

      // var collection = viewer.scene.primitives.add(new Cesium.ModelInstanceCollectionzh({
      //     url: "http://36.7.136.132:8099/img/model/飞机1.gltf",
      //     instances: instances,
      //     color: Cesium.Color.ORANGERED
      // }));

      var k = 0;
      Cesium.Scene.prototype.screenToWorld = L;
      function L(t, n) {
        if (viewer.canvas.width <= 0 || viewer.canvas.height <= 0) return;
        if (k > 0) return;
        var r = {
          level: 16,
          callback: function (s) {
            console.log(s);
          },
          pickPrimitive: undefined,
          pick: undefined,
          includeUndergroundSurface: !0,
        };
        var i = $.extend(!0, {}, r, n);
        var s;
        var o;
        try {
          k++;
          o = viewer.scene.pick(t);
        } catch (u) {
          console.log("Pick error!");
        } finally {
          k--;
        }
        var a =
          i.includeUndergroundSurface &&
          Cesium.defined(o) &&
          Cesium.defined(o.id) &&
          o.id == "undergroundSurface";
        if (
          Cesium.defined(o) &&
          Cesium.defined(o.primitive) &&
          viewer.scene.pickPositionSupported
        )
          viewer.scene.pickTranslucentDepth &&
            o.primitive._appearance &&
            o.primitive._appearance.translucent &&
            C(),
            (s = viewer.scene.pickPosition(t)),
            i.callback != undefined && i.callback(s);
        // else if (viewer.scene.pickPositionSupported)
        //     s = viewer.scene.pickPosition(t),
        //         i.callback != undefined && i.callback(s);
        else {
          var f = viewer.camera.getPickRay(t);
          s = viewer.scene.globe.pick(f, viewer.scene);
          if (i.callback != undefined) {
            var l = viewer.scene.globe.ellipsoid.cartesianToCartographic(s),
              c = Cesium.sampleTerrain(viewer.terrainProvider, i.level, [l]);
            Cesium.when(c, function (e) {
              e[0].height != undefined &&
                (s = viewer.scene.globe.ellipsoid.cartographicToCartesian(
                  e[0]
                )),
                i.callback(s);
            });
          }
        }
        return (
          n != undefined &&
            o != undefined &&
            ((n.pickPrimitive = o.primitive), (n.id = o.id), (n.pick = o)),
          s
        );
      }
      var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
      handler.setInputAction(function (e) {
        var n = {};
        viewer.scene.screenToWorld(e.position, n);
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    </script>
  </body>
</html>
